#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "rngs.h"
#include "testhelpers.c"

// This function tests sea_hag

void setHand(struct gameState *state){
    state->hand[0][0] = sea_hag;
    state->handCount[0] = 1;
}

int main(){
    int i;
    struct gameState *state = malloc(sizeof(struct gameState));
    setState(state);
    resetDeck(state);
    setHand(state);

    printf("starting Sea Hag Card Effect Test\n");

    resetFlag();

    cardEffect(sea_hag, 0, 0, 0, state, 0, 0);

    // sea hag forces each player to discard the top card of their deck and replace it with a curse
    if(state->handCount[0] != 1)
        assertMessage("Handcount should be %d but it is %d\n", 1, state->handCount[0]);
    if(state->playedCardCount != 1)
        assertMessage("Played Card Count should be %d but it is %d\n", 1, state->playedCardCount);
    if(state->playedCards[0] != sea_hag)
        assertMessage("Played Card should be %d but it is %d\n", sea_hag, state->playedCards[0]);
    for(i = 1; i < state->numPlayers; i++){
        if(state->discardCount[i] != 1){
            printf("For player %d ", i);
            assertMessage("Discard Count should be %d but it is %d\n", 1, state->discardCount[i]);
        }
        if(state->deck[i][0] != curse){
            printf("For player %d ", i);
            assertMessage("First card of the deck should be %d but it is %d\n", curse, state->deck[i][0]);
        }
    }

    if(testState() == 0)
        printf("Sea Hag Card Effect Test Passed\n");
    else
        printf("Sea Hag Card Effect Test Failed\n");

    free(state);
    return 0;
}
